package pro.vet.DAO;

import java.io.Reader;
import java.util.ArrayList;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import pro.vet.beans.DocumentoOrdenBean;
import pro.vet.beans.cita;
import pro.vet.services.DocumentoOrden_Services;

public class DocumentoOrden_DAO implements DocumentoOrden_Services{

	SqlSessionFactory sqlmapper= null;{
	   	 try {
				
			
	   	 Reader reader = Resources.getResourceAsReader("ConfiguracionIbatis.xml");
	   	 
	   	 sqlmapper =new  SqlSessionFactoryBuilder().build(reader);
	   	 } catch (Exception e) {
					e.printStackTrace();
				}
	    }
	
	@Override
	public ArrayList<DocumentoOrdenBean> listarDocumentoOrden(
			DocumentoOrdenBean doc) throws Exception {
		ArrayList<DocumentoOrdenBean> lista = null;
		SqlSession session = sqlmapper.openSession();
		try {
			
			lista= (ArrayList<DocumentoOrdenBean>)session.selectList("DocumentoOrdenXML.listar_OrdenCompra",doc);
			
		} catch (Exception e) {
			e.printStackTrace();
		}finally{ session.close();}
		System.out.println("LISTAD::"+lista.get(0).getNumeroDoc());
		return lista;
		
	}

}
